package com.wkq.util.transformer

import android.view.View
import androidx.viewpager2.widget.ViewPager2

/**
 *
 *@Author: wkq
 *
 *@Time: 2025/7/28 17:59
 *
 *@Desc: 3. 书本翻页（FlipPageTransformer）
 */
class FlipPageTransformer : ViewPager2.PageTransformer {
    override fun transformPage(view: View, position: Float) {
        view.cameraDistance = 20000f
        when {
            position < -1 -> view.alpha = 0f
            position <= 0 -> {
                view.alpha = 1f
                view.pivotX = view.width.toFloat()
                view.rotationY = 180 * position
            }
            position <= 1 -> {
                view.alpha = 1f
                view.pivotX = 0f
                view.rotationY = 180 * position
            }
            else -> view.alpha = 0f
        }
    }
}
